
import java.awt.Color;
import java.awt.Dimension;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTable;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.PiePlot3D;
import org.jfree.data.general.DefaultPieDataset;
import org.jfree.data.general.PieDataset;
import org.jfree.util.Rotation;


public class Torta_Apostador extends JFrame{

	private static final long serialVersionUID = 1L;
	public static  JTable tableDeReportes;

    @SuppressWarnings("static-access")
	public Torta_Apostador(String s,JTable tableDeReportes)
    {
    	super(s);
        this.tableDeReportes=tableDeReportes;
        JPanel jpanel = createDemoPanel();
        jpanel.setPreferredSize(new Dimension(600, 400));
        setContentPane(jpanel);
        pack();
        setVisible(true);
     
    }

    private static JFreeChart createChart(PieDataset piedataset)
    {
        JFreeChart jfreechart = ChartFactory.createPieChart3D("REPORTE APOSTADOR", piedataset, true, false, false);
       
        jfreechart.setBackgroundPaint(Color.getHSBColor(900, 500, 333));
       
        return jfreechart;
    }

    private static PieDataset createDataset()
    {
        DefaultPieDataset defaultpiedataset = new DefaultPieDataset();
        defaultpiedataset.setValue("Cantidad de Apostadores",(Number) tableDeReportes.getValueAt(15, 1));
        defaultpiedataset.setValue("Ganador", (Number) tableDeReportes.getValueAt(25, 1));
        defaultpiedataset.setValue("Perdedor", (Number) tableDeReportes.getValueAt(26, 1));
       
        return defaultpiedataset;
    }

    public static JPanel createDemoPanel()
    {
        JFreeChart jfreechart = createChart(createDataset());
        Rotator rotator = new Rotator((PiePlot3D)jfreechart.getPlot());
        rotator.start();
        return new ChartPanel(jfreechart);
    }
}
